<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
    <link rel="stylesheet" href="../css/taxbillservice.css" media="all">
</head>
<style>
    .layui-inline{margin-bottom: 15px;}
</style>
<body>
<div class="layuimini-container">
    <div class="title">
        <em></em>
        <h3>税单管理</h3>
    </div>
    <form class="layui-form layui-form-padding" action="">
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="tel" name="sellerName" placeholder="请输入客户名称" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" name="companyName" placeholder="请输入公司名称" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" name="serviceName" placeholder="请输入服务商名称" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <button class="layui-btn" lay-submit="" lay-filter="searchBtn">查询</button>
                <button type="reset" class="layui-btn layui-btn-primary">清空</button>
            </div>
        </div>
    </form>
    <form class="layui-form layui-form-padding-right" action="">
        <div class="layui-inline">
            <div class="layui-input-inline">
                <button type="button" class="layui-btn layui-btn-primary" lay-submit="" lay-filter="demo1">新增税单</button>
            </div>
        </div>
    </form>
    <div class="layuimini-main">
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

    </div>
    <script type="text/html" id="currentTableBar">
        <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" target="_blank" href="{{d.taxPic}}">下载税单</a>
    </script>

</div>
<script src="../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    var this_ = '',tableIns = '';
    layui.use(['form', 'table','jquery','tfApi'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            $ = layui.jquery,
            this_ = $,
            API = layui.tfApi;

        tableIns = table.render({
            elem: '#currentTableId',
            url: API.CURL + '/service/qryTaxByServiceId',
            cellMinWidth: 60,
            method: "POST",
            contentType: 'application/json',
            xhrFields: {withCredentials: true},crossDomain: true,
            request:{
                pageName: "page",
                limitName : "pageSize"
            },
            parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.list, //解析数据列表
                };
            },
            cols: [[
                {field: 'id', title:'id',hide:true},
                {field: 'sellerId', title:'sellerId',hide:true},
                {field: 'serviceId', title:'serviceId',hide:true},
                {field: 'sellerName', title: '商户名称',minWidth:300},
                {field: 'sellerCompanyName', title: '公司名称',minWidth:300},
                {field: 'serviceName',  title: '服务商名称',minWidth:300},
               /* {field: 'taxPic', title: '税单图片',templet: function(d){
                        return '<div id="bigImg" onclick="show_img(this)" ><img src="'+d.taxPic+'" alt="" width="50px" height="50px" ></a></div>';
                    }
                },

                */
                {field: 'taxMonth', title: '税单月份'},
                {field: 'taxUrl', title: '操作',toolbar: '#currentTableBar', align: "center"},
            ]],
            page: true,
            //skin: 'line'
        });


        //监听提交
        form.on('submit(searchBtn)', function (data) {

            var sellerName = $("input[name='sellerName']").val(),
                companyName = $("input[name='companyName']").val(),
                serviceName = $("input[name='serviceName']").val();
            let query_y = {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                , done: function (res, curr, count) {
                    //完成后重置where，解决下一次请求携带旧数据
                    //  this.where = {};
                }
            };

            query_y.where = {
                "sellerName" : sellerName,
                "companyName" : companyName,
                "serviceName" : serviceName
            };
            tableIns.reload(query_y);
            return false;

        });


        //监听提交
        form.on('submit(demo1)', function (data) {
            var index = layer.open({
                title: '新增税单',
                type: 2,
                shade: 0.2,
                maxmin:true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: '../page/table/addtaxbill.html',
                end:function(){
                    location.reload();
                }
            });
            $(window).on("resize", function () {
                layer.full(index);
            });
            return false;
        });

    });
    function show_img(t) {
        console.log("----->",t)
        var t = this_(t).find("img");
        //页面层
        layer.open({
            type: 1,
            skin: 'layui-layer-rim', //加上边框
             area: ['80%', '80%'], //宽高
            shadeClose: true, //开启遮罩关闭
            end: function (index, layero) {
                return false;
            },
            content: '<div style="text-align:center"><img src="' + this_(t).attr('src') + '" /></div>'
        });
    }
</script>

</body>
</html>